package com.jimmy.medical.entity;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.util.Set;
import java.util.TreeSet;

/**
 * 订单
 *
 * @author jimmy
 * @since 0.1
 */
@Entity
@Table(name = "orders")
public class Order extends AbstractEntity {
    /**
     * 订单会员
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "member_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private Member member;
    /**
     * 订单类型,1:体检;2:陪诊;3:挂号;4:评估,5:购买会员
     */
    @Column(name = "order_type", length = 10)
    private String orderType;
    /**
     * 订单日期
     */
    @Column(name = "order_date", length = 20)
    private String orderDate;
    /** 关联的充值记录，用以确定是否收费*/
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "recharge_record_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private RechargeRecord rechargeRecord;
    /**
     * 医院
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "hospital_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private Hospital hospital;
    /**
     * 科室
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "department_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private HospitalDepartment department;
    /**
     * 医生
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "doctor_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private Doctor doctor;
    /**
     * 备注
     */
    @Column(name = "remarks", length = 2000)
    private String remarks;
    /**
     * 订单状态
     */
    @Column(name = "status", length = 10)
    private String status;

    /**
     * 体检项目
     */
    @ManyToMany(cascade={CascadeType.REMOVE}, fetch=FetchType.LAZY)
    @JoinTable(name="order_item",joinColumns={@JoinColumn(name="order_id",referencedColumnName="id")},inverseJoinColumns={@JoinColumn(name="item_id",referencedColumnName="id")})
    private Set<HealthCheckItems> healthCheckItems = new TreeSet<HealthCheckItems>();

    @Column(name = "create_time", length = 20)
    private String createTime;
    @Column(name = "create_user", length = 50)
    private String createUser;
    @Column(name = "update_time", length = 20)
    private String updateTime;
    @Column(name = "update_user", length = 50)
    private String updateUser;
    /**
     * 挂号状态
     **/
    @Column(name = "sign_status")
    private Integer signStatus;

    /**
     * 就诊时间
     **/
    @Column(name = "order_time")
    private String orderTime;

    /**
     * 垫付的金额，元
     **/
    @Column(name = "pay_amount")
    private Integer payAmount;

    /**
     * 垫付的内容
     **/
    @Column(name = "pay_content")
    private String payContent;

    /**
     * 客户是否已付0/1
     **/
    @Column(name = "is_member_pay")
    private Integer isMemberPay;

    /**
     * 成本的金额，元
     **/
    @Column(name = "cost_amount")
    private Integer costAmount;

    /**
     * 成本的内容
     **/
    @Column(name = "cost_content")
    private String costContent;

    /**
     * 是否产生成本 0/1
     **/
    @Column(name = "is_cost")
    private Integer isCost;

    /**
     * 是否恢复次数 0/1
     **/
    @Column(name = "is_recovery_counts")
    private Integer isRecoveryCounts;

    /**
     * 取消原因
     **/
    @Column(name = "cancel_reason")
    private String cancelReason;

    /**
     * 取消时间
     **/
    @Column(name = "cancel_time")
    private String cancelTime;

    /**
     * 标记首页提示的已读状态
     */
    @Column(name = "is_sign_read", length = 2)
    private String isSignRead;

    @Column(name = "is_report_read", length = 2)
    private String isReportRead;

    @Column(name = "is_evaluation_read", length = 2)
    private String isEvaluationRead;

    /**
     * 陪诊人
     */
    @Column(name = "diagnose_user", length = 50)
    private String diagonseUser;

    /**
     * 费用处理人
     */
    @Column(name = "fee_process_user", length = 50)
    private String feeProcessUser;

    /**
     * 挂号人
     */
    @Column(name = "sign_user", length = 50)
    private String signUser;

    /**
     * 初步处理人
     */
    @Column(name = "simple_process_user", length = 50)
    private String simpleProcessUser;

    /**
     * 执行人,添加陪诊报告、体检报告等
     */
    @Column(name = "execute_user", length = 50)
    private String executeUser;

    /**
     * 订单审核人
     */
    @Column(name = "approve_user", length = 50)
    private String approveUser;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "service_user_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private User serviceUser;

    /** 订单关联的服务项目*/
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "service_item_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private ServiceItem serviceItem;

    /**
     * 组别，用于按组划分订单，取值为派单用户的unitCode
     */
    @Column(name = "unit_code", length = 10)
    private String unitCode;

    /** 是否扣减次数*/
    @Column(name = "deduct", length = 10)
    private String deduct;

    /** 垫付费用支付流水号*/
    @Column(name = "pay_flow_no", length = 20)
    private String payFlowNo;

    public Member getMember() {
        return member;
    }

    public void setMember(Member member) {
        this.member = member;
    }

    public String getOrderType() {
        return orderType;
    }

    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }

    public String getOrderDate() {
        return orderDate;
    }

    public void setOrderDate(String orderDate) {
        this.orderDate = orderDate;
    }

    public RechargeRecord getRechargeRecord() {
        return rechargeRecord;
    }

    public void setRechargeRecord(RechargeRecord rechargeRecord) {
        this.rechargeRecord = rechargeRecord;
    }

    public Hospital getHospital() {
        return hospital;
    }

    public void setHospital(Hospital hospital) {
        this.hospital = hospital;
    }

    public HospitalDepartment getDepartment() {
        return department;
    }

    public void setDepartment(HospitalDepartment department) {
        this.department = department;
    }

    public Doctor getDoctor() {
        return doctor;
    }

    public void setDoctor(Doctor doctor) {
        this.doctor = doctor;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public String getUpdateUser() {
        return updateUser;
    }

    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }

    public Integer getSignStatus() {
        return signStatus;
    }

    public void setSignStatus(Integer signStatus) {
        this.signStatus = signStatus;
    }

    public String getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(String orderTime) {
        this.orderTime = orderTime;
    }

    public Integer getPayAmount() {
        return payAmount;
    }

    public void setPayAmount(Integer payAmount) {
        this.payAmount = payAmount;
    }

    public String getPayContent() {
        return payContent;
    }

    public void setPayContent(String payContent) {
        this.payContent = payContent;
    }

    public Integer getIsMemberPay() {
        return isMemberPay;
    }

    public void setIsMemberPay(Integer isMemberPay) {
        this.isMemberPay = isMemberPay;
    }

    public Integer getCostAmount() {
        return costAmount;
    }

    public void setCostAmount(Integer costAmount) {
        this.costAmount = costAmount;
    }

    public String getCostContent() {
        return costContent;
    }

    public void setCostContent(String costContent) {
        this.costContent = costContent;
    }

    public Integer getIsCost() {
        return isCost;
    }

    public void setIsCost(Integer isCost) {
        this.isCost = isCost;
    }

    public Integer getIsRecoveryCounts() {
        return isRecoveryCounts;
    }

    public void setIsRecoveryCounts(Integer isRecoveryCounts) {
        this.isRecoveryCounts = isRecoveryCounts;
    }

    public String getCancelReason() {
        return cancelReason;
    }

    public void setCancelReason(String cancelReason) {
        this.cancelReason = cancelReason;
    }

    public String getCancelTime() {
        return cancelTime;
    }

    public void setCancelTime(String cancelTime) {
        this.cancelTime = cancelTime;
    }

    public User getServiceUser() {
        return serviceUser;
    }

    public void setServiceUser(User serviceUser) {
        this.serviceUser = serviceUser;
    }

    public ServiceItem getServiceItem() {
        return serviceItem;
    }

    public void setServiceItem(ServiceItem serviceItem) {
        this.serviceItem = serviceItem;
    }

    public String getUnitCode() {
        return unitCode;
    }

    public void setUnitCode(String unitCode) {
        this.unitCode = unitCode;
    }

    public String getIsSignRead() {
        return isSignRead;
    }

    public void setIsSignRead(String isSignRead) {
        this.isSignRead = isSignRead;
    }

    public String getIsReportRead() {
        return isReportRead;
    }

    public void setIsReportRead(String isReportRead) {
        this.isReportRead = isReportRead;
    }

    public String getIsEvaluationRead() {
        return isEvaluationRead;
    }

    public void setIsEvaluationRead(String isEvaluationRead) {
        this.isEvaluationRead = isEvaluationRead;
    }

    public String getDiagonseUser() {
        return diagonseUser;
    }

    public void setDiagonseUser(String diagonseUser) {
        this.diagonseUser = diagonseUser;
    }

    public String getFeeProcessUser() {
        return feeProcessUser;
    }

    public void setFeeProcessUser(String feeProcessUser) {
        this.feeProcessUser = feeProcessUser;
    }

    public String getSignUser() {
        return signUser;
    }

    public void setSignUser(String signUser) {
        this.signUser = signUser;
    }

    public String getSimpleProcessUser() {
        return simpleProcessUser;
    }

    public void setSimpleProcessUser(String simpleProcessUser) {
        this.simpleProcessUser = simpleProcessUser;
    }

    public String getExecuteUser() {
        return executeUser;
    }

    public void setExecuteUser(String executeUser) {
        this.executeUser = executeUser;
    }

    public String getApproveUser() {
        return approveUser;
    }

    public void setApproveUser(String approveUser) {
        this.approveUser = approveUser;
    }

    public Set<HealthCheckItems> getHealthCheckItems() {
        return healthCheckItems;
    }

    public void setHealthCheckItems(Set<HealthCheckItems> healthCheckItems) {
        this.healthCheckItems = healthCheckItems;
    }

    public String getDeduct() {
        return deduct;
    }

    public void setDeduct(String deduct) {
        this.deduct = deduct;
    }

    public String getPayFlowNo() {
        return payFlowNo;
    }

    public void setPayFlowNo(String payFlowNo) {
        this.payFlowNo = payFlowNo;
    }
}
